package naga.x.platform2.channel.meitu.support;

import org.springframework.beans.factory.InitializingBean;
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.context.annotation.Configuration;

import naga.x.platform2.App;
import naga.x.platform2.app.Channel;
import naga.x.platform2.support.RequestPath;

@Configuration
@EnableAutoConfiguration
@ConfigurationProperties(locations = "classpath:meitu.properties")
public class MeiTuConfig implements InitializingBean {

	private boolean debug;
	private String gameId;
	private String secretKey; // 签名秘钥
	private String apiUrl; // 平台接口地址
	private String clientUrl;
	private String payCallbackUrl; // 充值回调地址

	public boolean isDebug() {
		return debug;
	}

	public void setDebug(boolean debug) {
		this.debug = debug;
	}

	public String getGameId() {
		return gameId;
	}

	public void setGameId(String gameId) {
		this.gameId = gameId;
	}

	public String getSecretKey() {
		return secretKey;
	}

	public void setSecretKey(String secretKey) {
		this.secretKey = secretKey;
	}

	public String getClientUrl() {
		return clientUrl;
	}

	public void setClientUrl(String clientUrl) {
		this.clientUrl = clientUrl;
	}

	public String getApiUrl() {
		return apiUrl;
	}

	public void setApiUrl(String apiUrl) {
		this.apiUrl = apiUrl;
	}
	
	public String getPayCallbackUrl() {
		return payCallbackUrl;
	}

	@Override
	public String toString() {
		return "[debug=" + debug + ", gameId=" + gameId + ", secretKey=" + secretKey + ", apiUrl=" + apiUrl
				+ ", clientUrl=" + clientUrl + ", payCallbackUrl=" + payCallbackUrl + "]";
	}

	@Override
	public void afterPropertiesSet() throws Exception {
		Channel.MEITU.debug = debug;
		payCallbackUrl = App.getInstance().getUrl() + RequestPath.MEITU_PAY_CALLBACK;
		App.LOG.info("[MEITU CONFIG LOADED]{}", this);
	}

}
